package com.yuexunit.finance.member.action.v1;

import java.util.List;

import com.yuexunit.finance.common.util.BeanUtils;
import com.yuexunit.finance.member.action.v1.model.MonthBillDetail;
import com.yuexunit.finance.member.entity.MonthBillEntity;
import com.yuexunit.finance.member.service.MonthBillService;
import com.yuexunit.finance.member.service.MonthEarningService;
import com.yuexunit.inject.ComponentFactory;
import com.yuexunit.inject.annotation.Implements;

@Implements(MonthBillApi.class)
public class MonthBillApiImpl implements MonthBillApi {
	
	private MonthBillService monthBillService = ComponentFactory.loadClass(MonthBillService.class);

	private MonthEarningService monthEarningService = ComponentFactory.loadClass(MonthEarningService.class);

	@Override
	public MonthBillDetail selectMonthBillDetail(Integer year,
			Integer month) {
		List<MonthBillEntity> monthBillEntityList = monthBillService.selectMonthBillDetail(year, month);
		if(monthBillEntityList == null || monthBillEntityList.size() == 0) {
			return null;
		}
		
		MonthBillEntity monthBillEntity = monthBillEntityList.get(0);
		MonthBillDetail monthBillDetail = new MonthBillDetail();
		BeanUtils.copyProperties(monthBillEntity, monthBillDetail);
		
		return monthBillDetail;
	}

	@Override
	public MonthBillDetail selectMonthBillDetailNew() {
		List<MonthBillEntity> monthBillList = monthBillService.selectMonthBillDetailNew();
		if(monthBillList == null || monthBillList.size() == 0) {
			return null;
		}
		
		MonthBillEntity monthBillEntity = monthBillList.get(0);
		MonthBillDetail monthBillDetail = new MonthBillDetail();
		BeanUtils.copyProperties(monthBillEntity, monthBillDetail);
		
		return monthBillDetail;
	}

}
